package com.woniu.liuzhougov.businessproject.service.impl;

import com.woniu.liuzhougov.businessproject.dao.BusinessProjectMapper;
import com.woniu.liuzhougov.businessproject.dto.BusinessProjectDTO;
import com.woniu.liuzhougov.businessproject.dto.BusinessProjectInitDTO;
import com.woniu.liuzhougov.businessproject.pojo.BusinessProject;
import com.woniu.liuzhougov.businessproject.service.BusinessProjectService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * @Description: 招商管理业务层实现
 * @author: Chris
 * @createDate: 2019/4/18 0018
 * @version: 1.0
 */
@Service
public class BusinessProjectServiceImpl implements BusinessProjectService {

    @Autowired
    private BusinessProjectMapper businessProjectMapper;

    //获取所有招商项目
    @Override
    public List<BusinessProjectDTO> selectBusinessProjects() {
        return businessProjectMapper.selectBusinessProjectsList();
    }

    @Override
    public List<BusinessProjectDTO> selectProject(BusinessProject businessProject) {
        return businessProjectMapper.selectProject(businessProject);
    }

    @Override
    @Transactional
    public int addBusinessProject(BusinessProject businessProject) {
        return businessProjectMapper.insert(businessProject);
    }

    @Override
    public BusinessProjectInitDTO initUpdateForm(Integer businessProjectId) {
        return businessProjectMapper.initUpdateForm(businessProjectId);
    }

    @Override
    @Transactional
    public int updateBusinessProject(BusinessProject businessProject) {
        return businessProjectMapper.updateByPrimaryKeySelective(businessProject);
    }

    @Override
    @Transactional
    public int deleteByPrimaryKey(Integer businessProjectId) {
        return businessProjectMapper.deleteByPrimaryKey(businessProjectId);
    }

    @Override
    public BusinessProject selectProjectByID(Integer businessProjectId) {
        return businessProjectMapper.selectByPrimaryKey(businessProjectId);
    }
}
